var threadedManager = new MultithreadedScheduler();

var circleOptions = {
    color: '#00ff00',
    position: new Point(50, 50),
    velocity: new Point(1, 1),
    radius: 42
};

var drawFps = 1000/30;

window.onload = function() {
    initScene();
}

var clearScreen = function(canvas, context) {
    context.clearRect(0, 0, canvas.width, canvas.height);
}

var initScene = function() {
    var canvas = document.getElementById('playground');
    var context = canvas.getContext('2d');
    
    var boundaryEngine = new BoundaryManager(
        new Point(0, 0), 
        new Point(canvas.width, canvas.height)
    );
    
    circleOptions.context = context;
    
    var circle = new Circle(circleOptions);
    
    var drawThread = new Thread(function() {
        clearScreen(canvas, context);
        circle.draw();
    }, drawFps);
    
    var updateThread = new Thread(function() {
        boundaryEngine.checkBoundary(circle);
        circle.update();
    }, drawFps * .25);
    
    var threadIds = [];
    threadIds.push(threadedManager.addThread(drawThread));
    threadIds.push(threadedManager.addThread(updateThread));
    
    for(threadId in threadIds) {
        threadedManager.runThread(threadId);
    }
}